package cn.com.twoke.application.game.mario.game.config;

import lombok.AccessLevel;
import lombok.Builder;
import lombok.Getter;

@Getter
@Builder(access = AccessLevel.PRIVATE)
public class Tiles {

    public static final int TILE_WIDTH = 16;
    public static final int TILE_HEIGHT = 16;

    public static final float SCALE = Settings.scale();

    private int cols;
    private int rows;


    public static Tiles form(int width, int height) {
        return Tiles.builder().cols(width / widthOf(1))
                .rows(height / heightOf(1)).build();
    }

    public static Tiles of(int cols, int rows) {
        return Tiles.builder().cols(cols)
                .rows(rows).build();
    }


    public static int scaleOf(float num) {
        return  (int) (num * SCALE);
    }

    public static int unscaleOf(float num) {
        return  (int) (num / SCALE);
    }

    public static int widthOf(int cols) {
        return (int) (TILE_WIDTH * SCALE * cols);
    }

    public static int heightOf(int rows) {
        return (int) ( TILE_HEIGHT * SCALE * rows);
    }


    public int getWidth() {
        return (int) (TILE_WIDTH * SCALE * cols);
    }

    public int getHeight() {
        return (int) (TILE_HEIGHT * SCALE * rows);
    }


}
